using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;

namespace rocketjump
{
    public static class SoundHelper
    {
        static Game parent;
        static private bool playingOwnMusic = false;
        public static void Initialize(Game game)
        {
            parent = game;
        }
        public static void PlaySound(String snd)
        {
            SoundEffect SE = parent.Content.Load<SoundEffect>(snd);
            SE.Play();
        }

        public static void PlaySound(String snd, float volume)
        {
            SoundEffect SE = parent.Content.Load<SoundEffect>(snd);
            SE.Play(volume, 0.0f, 0.0f);
        }

        public static void PlayMusic(String music)
        {
            Song s = parent.Content.Load<Song>(music);
            if (MediaPlayer.State != MediaState.Playing || playingOwnMusic)
            {
                MediaPlayer.IsRepeating = true;
                MediaPlayer.Play(s);
                playingOwnMusic = true;
            }
        }

        public static void StopMusic()
        {
            if (MediaPlayer.State == MediaState.Playing && playingOwnMusic)
            {
                MediaPlayer.Stop();
            }
        }
    }
}
